{include file="public/public"}
<style type="text/css">
	#show tr td{
		overflow: hidden;
	}
	#show tr td p {
		width: 150px;
		float: left;
		text-align: center;
	}
	
</style>
<div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
	<div class="layui-body layui-tab-content site-demo site-demo-body">
		<div class="layui-tab-item layui-show">
			<div class="layui-main">
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
				</fieldset>
				<span class="layui-breadcrumb">
                    <a href="__APP__/{$menuConfigArry['functionMod']}/{$menuConfigArry['menuLabel']}">{$menuConfigArry['pmenuName']}</a>
                    <a><cite>{$menuConfigArry['menuName']}</cite></a>
                </span>
				<hr>
				<div class="layui-form-item" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">按酒店名</label>
						<div class="layui-input-inline">
							<input id='souname' name="text2" type="text" class="layui-input" />
						</div>
						<a href="#" onClick="subsou()" class="layui-btn ">搜索</a>
					</div>
					<div class="layui-inline">
						<a href="__APP__/admin/operationlog?type=hotel">操作日志</a>
					</div>
				</div>
				<table class="layui-table" lay-skin="line">
					<thead>
						<tr>
							<td width="75">选择</td>
							<td width="85">编号</td>
							<td width="267">酒店名</td>
							<td width="261">酒店程序名</td>
							<td width="261">酒店运营状态</td>
							<td width="180">操作</td>
						</tr>
					</thead>
					<tbody>
						<?
	                    if($roomArr){
	                      	foreach($roomArr as $val){
	                        $tmp = addslashes(json_encode($val));
	                     ?>
							<tr>
								<td><input type="checkbox" name="roombox" id="roombox" value="{$val[id]}"></td>
								<td>{$val[id]}</td>
								<td>{$val[hotel]}</td>
								<td>{$val[hotelName]}</td>
								<td>{$val[operationStatus]}</td>
								<td>
									<a href="#" class="layui-btn layui-btn-sm" onclick='edit("{$tmp}",2)'>修改 </a>
								</td>
							</tr>
							<?php
                        }
                    }
                ?>
					</tbody>
				</table>

				<div>管理操作全选
					<input type="checkbox" onClick="checkallstu(this)" />
					<input name="submit" type="submit" value="删除" onclick="delall()" class="layui-btn layui-btn-sm layui-btn-warm" />
					<input name="submit2" type="button" value="添加酒店" onclick="document.getElementById('show').style.display='block'" class="layui-btn layui-btn-sm" />
				</div>
				<div class="layui-box layui-laypage layui-laypage-default">{$page}</div>

				<FORM action="__APP__/admin/addhotel" enctype="multipart/form-data" method="post">
					<div id="show" style="display:none" class="show">
						<table class="layui-table">
							<colgroup>
								<col width="400">
								<col width="400">
							</colgroup>
							<thead>
								<tr>
									<td colspan="2">酒店名管理</td>
									<input type="hidden" id="id" name="id">
								</tr>
							</thead>
							<tbody>
								<!--<tr class="ctt_gr">
									<td>
										<div class="layui-form-item">
											<label class="layui-form-label">酒店名</label>
											<div class="layui-input-block">
												<input type="text" name="title" lay-verify="title" autocomplete="off" class="layui-input" id="hotel" name="hotel">
											</div>
										</div>
									</td>
									<td>
										<div class="layui-form-item">
											<label class="layui-form-label">单行输入框</label>
											<div class="layui-input-block">
												<input type="text" name="title" lay-verify="title" autocomplete="off" class="layui-input">
											</div>
										</div>
									</td>
								</tr>-->
								<tr class="ctt_gr">
									<td align="left" class="leftClass">
										<p>酒店中文名称：</p>
										<input class="textField_hp1" name="title" lay-verify="title" autocomplete="off" class="" id="hotel" name="hotel">
									</td>
									<td align="left">
										<p>试用开始时间：</p>
										<input class="textField_hp1" size="20" id="starttime1" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
										<p>酒店英文名称：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
									<td align="left">
										<p>试用结束时间：</p>
										<input class="textField_hp1" size="20" id="endtime1" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
										<p>酒店程序名称：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
									<td align="left">
										<p>合同开始时间：</p>
										<input class="textField_hp1" size="20" id="starttime2" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
										<p>详细中文地址：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
									<td align="left">
										<p>合同结束时间：</p>
										<input class="textField_hp1" size="20" id="endtime2" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td>
										<p>详细英文地址：</p>
										<input class="textField_hp1" size="20" id="" name="" /></td>
									<td>
										<p>合同编号：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
										<p>酒店vpnIP：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
									<td align="left">
										<p>前台总机：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
										<p>客房数量：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
									<td align="left">
										<p>酒管联系人：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td>
										<p>设备数量：</p>
										<input class="textField_hp1" size="20" id="" name="" /></td>
									<td>
										<p>酒管联系人电话：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">

									<td align="left">
										<p>添加时间：</p>
										<input class="textField_hp1" size="20" id="addtime" name="addtime" />
									</td>
									<td align="left">
										<p>酒管地址：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>

								<tr>
									<td align="left">
										<p>所属地区：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
									<td align="left">
										<p>酒管总经理：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
										<p>投影数量：</p>
										<input class="textField_hp1" size="20" id="XScount" name="XScount" />
									</td>
									<td align="left">
										<p>酒管总经理电话：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">

									<td align="left">
										<p>电视数量：</p>
										<input class="textField_hp1" size="20" id="TVcount" name="TVcount" />
									</td>
									<td align="left">
										<p>酒店总经理：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>

								<tr class="ctt_gr">
									<td align="left">
										<p>盒子数量：</p>
										<input class="textField_hp1" size="20" id="" name="" />

									</td>
									<td align="left">
										<p>酒店总经理电话：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>

								<tr class="ctt_gr">
									<td align="left">
										<p>酒店星级：</p>
										<select id="starlevel" name="starlevel">
											<option value="7">☆☆☆☆☆☆☆</option>
											<option value="6">☆☆☆☆☆☆</option>
											<option value="5">☆☆☆☆☆</option>
											<option value="4">☆☆☆☆</option>
											<option value="3">☆☆☆</option>
											<option value="2">☆☆</option>
											<option value="1">☆</option>
										</select>
									</td>
									<td align="left">
										<p>酒店营销总监：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">

									<td align="left">
										<p>所属集团：</p>
										<select id="hotelGroup" name="hotelGroup">
											<option value="0">无所属</option>
											<?php
                            if($hotelGroup){ foreach($hotelGroup as $varhotelGroup){
                         ?>

												<option value="{$varhotelGroup['id']}">{$varhotelGroup['groupname']}</option>
												<?php
                            }
                            }
                            ?>

										</select>
									</td>
									<td align="left">
										<p>酒店营销总监电话：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">

									<td align="left">
										<p>运营状态：</p>
										<select id="operationStatus" name="operationStatus">
											<option value="test" selected="selected">测试</option>
											<option value="trial">试运营</option>
											<option value="formal">正式运营</option>
										</select>
									</td>
									<td align="left">
										<p>酒店工程部联系人：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
										<p>所属区域：</p>
										<select id="operationStatus" name="operationStatus">
											<option value="test" selected="selected">1</option>
											<option value="trial">2</option>
											<option value="formal">3</option>
										</select>
									</td>
									<td align="left">
										<p>酒店工程部电话：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>

								<tr class="ctt_gr">
									<td align="left">
										<p>郊区与否：</p>
										<input class="" type="radio" checked size="20" id="" name="outskirts" />是
										<input class="" type="radio" style="margin-left: 10px;" size="20" id="" name="outskirts" />否
									</td>
									<td align="left">
										<p>酒店合同负责人：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
										<p>酒店标签：</p>
										<input class="" type="checkbox" checked size="20" id="" name="labelType" />1
										<input class="" style="margin-left: 5px;" type="checkbox" checked size="20" id="" name="labelType" />2
										<input class="" style="margin-left: 5px;" type="checkbox" checked size="20" id="" name="labelType" />3
									</td>
									<td align="left">
										<p>酒店合同负责人电话：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
										<p>服务器Key：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
									<td align="left">
										<p>渠道商负责人：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>

								<tr class="ctt_gr">
									<td align="left">
										<p>服务器IP地址：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
									<td align="left">
										<p>渠道商负责人电话：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
										<p>备注：</p>
										<input class="textField_hp1" size="20" id="PCcount" name="PCcount" />
									</td>
									<td align="left">
										<p>酒店发展顾问：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td align="left">
									</td>
									<td align="left">
										<p>酒店发展顾问电话：</p>
										<input class="textField_hp1" size="20" id="" name="" />
									</td>
								</tr>
									
								<tr class="ctt_gr">
									<td colspan='2' align="left">
										<p>所属地区：</p>
										<span>省：
											<select id="p" name="p">
		                        			<? if($list1){ foreach($list1 as $list){ ?>
		                                    	<option value="{$list['assign']}" >{$list['cityName']}</option>
		                                    <? }} ?>
                    						</select>
                        				</span>
										<span>市：
											<select id="c" name="c">
                        					<? if($list2){ foreach($list2 as $list){ ?>
                                        		<option value="{$list['assign']}">{$list['cityName']}</option>
                                        	<? }} ?>
                    						</select>
                   						</span>
										<span>县：
											<select id="x" name="x">
                        					<? if($list3){ foreach($list3 as $list){ ?>
	                                        	<option value="{$list['assign']}" >{$list['cityName']}</option>
	                                        <? }} ?>
                    						</select>
                   						 </span>
									</td>
								</tr>
								<tr>
									<td colspan='2' align="left">
										<div id="r-result" style='text-align:left;margin-left:40px;'>地址关键字:<input type="text" id="suggestId" size="20" style="width:150px;" />
											<input type='text' id='locNumLat'="" size="6" name='locNumLat' /><input type='text' id='locNumLng' name='locNumLng'="" size="6" />
										</div>
										<div id="searchResultPanel" style="border:1px solid #C0C0C0;width:120px;height:auto; display:none;"></div>
										<div id="allmap"></div>
										<input type='hidden' id='realaddr' name='realaddr' />
									</td>
								</tr>
								<tr class="ctt_gr">
									<td height="31" colspan="2" align="center">
										<input name="submit22" type="submit" value="确定" border="0" class="layui-btn" id="ok" />
										<input name="submit22" type="button" value="取消" border="0" onclick="document.getElementById('show').style.display='none'" class="layui-btn layui-btn-warm" />
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</FORM>
			</div>
		</div>
	</div>
</div>
<style type="text/css">
	#allmap {
		height: 300px;
		width: 90%;
		margin: 0px auto;
		overflow: hidden;
		font-family: "微软雅黑";
	}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ZFrrzgw9CzThkNn5p1KkfmUe59MtYivE"></script>

<script language="javascript">
	function checkallstu(o) {
		if(o.checked) {
			$("input[name='roombox']").attr("checked", true);
		} else {
			$("input[name='roombox']").attr("checked", false);
		}
	}

	function delall() {
		var arr = "";
		$("input[name=roombox]:checked").each(function() {
			arr += $(this).val() + ",";
		})
		if(arr == "") {
			alert('请选择要删除的记录');
			return false;
		}
		if(confirm("您确定要删除吗？")) {
			$.post("__APP__/admin/delallhotel", {
				arr: arr
			}, function(data) {
				if(data.msg == "1") {
					alert("删除成功");
					location.reload();
				} else {
					alert("删除失败");
				}
			}, "json");
		} else {
			return false;
		}
	}

	function edit(val, flag) {

		console.log(val);
		var json = JSON.parse(val);
		if(json.address) {
			setPlace(json.address);
		} else {
			setPlace('北京市');
		}

		$("#id").val(json.id);
		$("#hotel").val(json.hotel);
		$("#hotelName2").val(json.hotelName);
		$("#hotelIP").val(json.ipaddr);
		$("#starlevel").val(json.starlevel);
		$("#XScount").val(json.clientNo);
		$("#PCcount").val(json.clientNoPc);
		$("#TVcount").val(json.clientNoTv);
		$("#hotelGroup").val(json.groupId);
		$("#operationStatus").val(json.operationStatus);
		$("#addtime").val(json.addtime);

		$('#locNumLat').val(json.lat / 100000000);
		$('#locNumLng').val(json.lng / 100000000);
		$('#suggestId').val('');

		var citycode = json.citycode;

		var cityName1 = citycode.substr(0, 2);
		var cityName2 = citycode.substr(0, 4);
		var cityName3 = citycode;
		$("#p").val(cityName1);
		$.post("__APP__/admin/getcity2", {
			code: cityName1
		}, function(data) {
			$("#c").html(data);
			$("#c").val(cityName2);
			$.post("__APP__/admin/getcity2", {
				code: cityName2
			}, function(data) {
				$("#x").html(data);
				$("#x").val(cityName3);
			});
		});

		var movieInfo = json.demand.split("#");

		var name = movieInfo[0];
		var phone = movieInfo[1];
		var landline = movieInfo[2];
		var email = movieInfo[3];
		var other = movieInfo[4];
		$("#name").val(name);
		$("#phone").val(phone);
		$("#landline").val(landline);
		$("#email").val(email);
		$("#other").val(other);
		$("#show").show();
	}

	function subsou() {
		var souname = $("#souname").val();
		window.location.href = '__APP__/admin/hotelName?name=' + souname;
	}
</script>

<script>
	$('select[name=\'p\']').bind('change', function() {
		var code = $('select[name=\'p\']').val();
		var pname = $('#p option:selected').html() + ' ';
		$.post("__APP__/admin/getcity2", {
			code: code
		}, function(data) {
			$("#c").html(data);
			var code1 = $('select[name=\'c\']').val();
			$.post("__APP__/admin/getcity2", {
				code: code1
			}, function(data) {
				setPlace(pname);
				$("#x").html(data);
			});
		});
	});
	$('select[name=\'c\']').bind('change', function() {
		var code = $('select[name=\'c\']').val();
		var pname = $('#p option:selected').html() + ' ';
		var cname = pname + $('#c option:selected').html() + ' ';
		$.post("__APP__/admin/getcity2", {
			code: code
		}, function(data) {
			setPlace(cname);
			$("#x").html(data);
		});
	});
	$("#x").bind('change', function() {
		var xname = $('#p option:selected').html() + ' ' + $('#c option:selected').html() + ' ' + $('#x option:selected').html();
		setPlace(xname);
	});
	// 百度地图API功能
	function G(id) {
		return document.getElementById(id);
	}

	var map = new BMap.Map("allmap");
	map.centerAndZoom('北京', 12); // 初始化地图,设置城市和地图级别。
	map.enableScrollWheelZoom(true);
	map.setDefaultCursor("url('bird.cur')");
	var ac = new BMap.Autocomplete( //建立一个自动完成的对象
		{
			"input": "suggestId",
			"location": map
		});

	ac.addEventListener("onhighlight", function(e) { //鼠标放在下拉列表上的事件
		var str = "";
		var _value = e.fromitem.value;
		var value = "";
		if(e.fromitem.index > -1) {
			value = _value.province + _value.city + _value.district + _value.street + _value.business;
		}
		str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;

		value = "";
		if(e.toitem.index > -1) {
			_value = e.toitem.value;
			value = _value.province + _value.city + _value.district + _value.street + _value.business;
		}
		str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
		G("searchResultPanel").innerHTML = str;
	});

	var myValue;
	ac.addEventListener("onconfirm", function(e) { //鼠标点击下拉列表后的事件
		var _value = e.item.value;
		myValue = _value.province + _value.city + _value.district + _value.street + _value.business;
		G("searchResultPanel").innerHTML = "onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
		setPlace(myValue);
	});

	function showInfo(e) {
		map.clearOverlays();
		var zoomsize = map.getZoom();
		if(confirm('确认讲酒店定位此处？')) {
			$('#locNumLng').val(e.point.lng);
			$('#locNumLat').val(e.point.lat);
			map.addOverlay(new BMap.Marker(e.point));
		}
		//alert(e.point.lng + ", " + e.point.lat);
	}

	map.addEventListener("click", showInfo);

	function setPlace(loc) {
		map.clearOverlays(); //清除地图上所有覆盖物
		function myFun() {
			var pp = local.getResults().getPoi(0).point; //获取第一个智能搜索的结果
			map.centerAndZoom(pp, 16);
			map.addOverlay(new BMap.Marker(pp)); //添加标注
		}
		var local = new BMap.LocalSearch(map, { //智能搜索
			onSearchComplete: myFun
		});
		local.search(loc);
		var myGeo = new BMap.Geocoder();
		myGeo.getPoint(loc, function(point) {
			var geoc = new BMap.Geocoder();
			geoc.getLocation(point, function(rs) {
				var addComp = rs.addressComponents;
				var realaddr = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber;
				$('#realaddr').val(realaddr);
				changeOld(addComp.province, addComp.city, addComp.district);
			});
			$('#locNumLng').val(point.lng);
			$('#locNumLat').val(point.lat);
		}, '北京市');
	}

	function changeOld(pro, city, xian) {
		$('#p option').each(function() {
			if(pro.indexOf($(this).html()) >= 0) {
				var optpv = $(this).val();
				$("#p option[value='" + optpv + "']").attr('selected', true);
				$.post("__APP__/admin/getcity2", {
					code: optpv
				}, function(data) {
					$("#c").html(data);
					$('#c option').each(function() {
						if(city.indexOf($(this).html()) >= 0) {
							var optcv = $(this).val();
							$("#c option[value='" + optcv + "']").attr('selected', true);
							$.post("__APP__/admin/getcity2", {
								code: optcv
							}, function(data) {
								$("#x").html(data);
								$('#x option').each(function() {
									if(xian.indexOf($(this).html()) >= 0) {
										console.log($(this).html());
										var optxv = $(this).val();
										$("#x option[value='" + optxv + "']").attr('selected', true);
									}
								});
							});
						}
					});
				});
			}
		});
	}
</script>
<script type="text/javascript">
	layui.use('laydate', function(){
	  var laydate = layui.laydate;
	  
	  //执行一个laydate实例
	  laydate.render({
	    elem: '#starttime1',
	    type: 'datetime' //指定元素
	  });
	  laydate.render({
	    elem: '#endtime1',
	    type: 'datetime' //指定元素 //指定元素
	  });
	  laydate.render({
	    elem: '#starttime2',
	    type: 'datetime' //指定元素 //指定元素
	  });
	  laydate.render({
	    elem: '#endtime2',
	    type: 'datetime' //指定元素 //指定元素
	  });
	  laydate.render({
	    elem: '#addtime',
	    type: 'datetime' //指定元素 //指定元素
	  });
	});
</script>